package com.lovo.project.service.impl;

import com.lovo.project.dao.SalesVolumeDAO;
import com.lovo.project.model.SalesVolumeDO;
import com.lovo.project.service.SalesVolumeService;
import com.lovo.project.util.MyBatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.HashMap;
import java.util.List;

/**
 * @title  销售额统计业务实现
 * @author: yuyuan
 * @date: 2020/11/4 15:33
 */
public class SalesVolumeServiceImpl implements SalesVolumeService {
    @Override
    public List<SalesVolumeDO> findByMonth() {
        SqlSession sqlSession = MyBatisUtil.getSqlSession();
        SalesVolumeDAO salesVolumeDAO = sqlSession.getMapper(SalesVolumeDAO.class);
        List<SalesVolumeDO> list = salesVolumeDAO.selectByMonth();
        sqlSession.close();
        return list;
    }

    @Override
    public List<SalesVolumeDO> findByQuarter() {
        return null;
    }

    @Override
    public List<SalesVolumeDO> findByYear() {
        SqlSession sqlSession = MyBatisUtil.getSqlSession();
        SalesVolumeDAO salesVolumeDAO = sqlSession.getMapper(SalesVolumeDAO.class);
        List<SalesVolumeDO> list = salesVolumeDAO.selectByYear();
        sqlSession.close();
        return list;
    }

    @Override
    public Integer findCountOne() {
        SqlSession sqlSession = MyBatisUtil.getSqlSession();
        SalesVolumeDAO salesVolumeDAO = sqlSession.getMapper(SalesVolumeDAO.class);
        int value = salesVolumeDAO.selectCountOne();
        sqlSession.close();
        return value;
    }

    @Override
    public Integer findCountTwo() {
        SqlSession sqlSession = MyBatisUtil.getSqlSession();
        SalesVolumeDAO salesVolumeDAO = sqlSession.getMapper(SalesVolumeDAO.class);
        int value = salesVolumeDAO.selectCountTwo();
        sqlSession.close();
        return value;
    }

    @Override
    public Integer findCountThree() {
        SqlSession sqlSession = MyBatisUtil.getSqlSession();
        SalesVolumeDAO salesVolumeDAO = sqlSession.getMapper(SalesVolumeDAO.class);
        int value = salesVolumeDAO.selectCountThree();
        sqlSession.close();
        return value;
    }
}
